from functools import reduce

def sma_cn(data, N = 6, M = 1):
    return reduce(lambda x, y: x + [((N - M) * x[-1] + M * y) / N], data[1:], [data[0]])
    

def SMA_Rolling(close, N):
    return sma_cn(close, N)
    #return close.rolling(1).apply(sma_cn, args=(N,1), raw=True)